package de.g18.it0a.jlaser.domain;

import java.awt.Point;
import java.awt.geom.Point2D;


public class Position {

    private final int x;
    private final int y;

    private Point2D point;


    public Position(int aX, int aY) {
        x = aX;
        y = aY;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public Point2D getPoint() {
        if (point == null) {
            point = new Point(getX(), getY());
        }
        return point;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() + "[x=" + getX() + ",y=" + getY() + "]";
    }

    @Override
    public int hashCode() {
        return getPoint().hashCode();
    }

    @Override
    public boolean equals(Object aOther) {
        if (aOther == this) {
            return true;
        }
        if (!(aOther instanceof Position)) {
            return false;
        }

        Position other = (Position) aOther;
        return getPoint().equals(other.getPoint());
    }
}
